#!/bin/sh
if [ ! -e ${testsdir}/${testname}/use.drill ]
then
	if [ "$2" != "AXFR" ]
	then
		../pdns/sdig $nameserver $port "$1" $2 $3 $4 $5 | LC_ALL=C sort
	else
		../pdns/saxfr $nameserver $port "$1" $3 $4 | LC_ALL=C sort
	fi
fi
../pdns/nsec3dig $nameserver $port "$1" $2 > ${testsdir}/${testname}/nsec3dig.out 2>&1
if [ ! -e ${testsdir}/${testname}/skip-drill ]
then
	if [ ! -s trustedkeys ]
	then
		drill -a -p $port -o rd -D "$1" $2 @$nameserver > ${testsdir}/${testname}/drill.out 2>&1
		echo RETVAL: $? >> ${testsdir}/${testname}/drill.out
	else
		drill -a -p $port -o rd -D -S -k trustedkeys "$1" $2 @$nameserver > ${testsdir}/${testname}/drillchase.out 2>&1
		echo RETVAL: $? >> ${testsdir}/${testname}/drillchase.out
		drill -a -p $port -o rd -D -k trustedkeys "$1" $2 @$nameserver > ${testsdir}/${testname}/drill.out 2>&1
		echo RETVAL: $? >> ${testsdir}/${testname}/drill.out
	fi
fi
if [ ! -e ${testsdir}/${testname}/skip-q ]
then
	/usr/lib/go/bin/q -tcp=true -short=true -rd=false -check -dnssec -port=$port @$nameserver $2 "$1" > ${testsdir}/${testname}/q.out 2>&1
	echo RETVAL: $? >> ${testsdir}/${testname}/q.out
fi
if [ ! -e ${testsdir}/${testname}/skip-unboundhost ]
then
	unbound-host -v -C unbound-host.conf -t $2 "$1" > ${testsdir}/${testname}/unbound-host.out 2>&1
	echo RETVAL: $? >> ${testsdir}/${testname}/unbound-host.out
fi
if [ -e ${testsdir}/${testname}/use.drill ]
then
	cat ${testsdir}/${testname}/drill.out | sed 's/ ;.*//'
fi
grep -iw bogus ${testsdir}/${testname}/*.out
